//
//  TradePageController.m
//  CEX
//
//  Created by xiebin on 2018/1/11.
//  Copyright © 2018年 mingthink. All rights reserved.
//

#import "TradePageController.h"
#import "CoinSelectView.h"
@interface TradePageController ()
{
    BOOL isShow;
}
@property(nonatomic,retain)CoinSelectView *dropDownView;
@end

@implementation TradePageController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNavigationView];
    [self addMenuViewBottomLine];
    [self addDropDownMenu];
}
- (void)initNavigationView{
    self.navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEVW, NAVBAR_HEIGH)];
    self.navView.backgroundColor = GET_HEX_COLOR(NAVBAR_BG_COLOR);
    [self.view addSubview:self.navView];
}
-(void)addMenuViewBottomLine{
    UIView *view_separateLine = UIView.new;
    view_separateLine.tag = 110;
    [self.menuView addSubview:view_separateLine];
    view_separateLine.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_GRAY);
    view_separateLine.layer.shadowColor = GET_HEX_COLOR(TABLE_SEPARATOR_GRAY).CGColor;//shadowColor阴影颜色
    view_separateLine.layer.shadowOffset = CGSizeMake(0,1);//shadowOffset阴影偏移,x向右偏移0，y向下偏移4
    view_separateLine.layer.shadowOpacity = 0.9;//阴影透明度，默认0
    view_separateLine.layer.shadowRadius = 1;
    view_separateLine.sd_layout.bottomSpaceToView(self.menuView,0).leftEqualToView(self.menuView).rightEqualToView(self.menuView).heightIs(0.5);
}
-(void)addDropDownMenu{
    UIButton *btn_dropDown = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.navView addSubview:btn_dropDown];
    [btn_dropDown setTitle:@"BTC/USDT" forState:UIControlStateNormal];
    [btn_dropDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn_dropDown.titleLabel.font = GET_SYSTEM_FONT(TEXT_FONT_34);
    [btn_dropDown addTarget:self action:@selector(dropDownClick) forControlEvents:UIControlEventTouchUpInside];
    btn_dropDown.sd_layout.topSpaceToView(self.navView,STATUS_HEIGH+7).leftSpaceToView(self.navView,50).rightSpaceToView(self.navView,50).heightIs(30);

}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    return CGRectMake(0, NAVBAR_HEIGH, DEVW, 40);
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    return CGRectMake(0, originY, DEVW, self.view.frame.size.height -originY-TABBAR_HEIGH);
}
-(void)dropDownClick{
    isShow=!isShow;
    if (isShow) {
        [self.dropDownView showInView:self.view];
        [self.view bringSubviewToFront:self.navView];
    }else{
        [self.dropDownView removeSelectView];
    }
}
-(CoinSelectView *)dropDownView{
    if (!_dropDownView) {
        _dropDownView=[[CoinSelectView alloc]initWithFrame:CGRectMake(0, NAVBAR_HEIGH, DEVW, DEVH-NAVBAR_HEIGH-TABBAR_HEIGH)];
    }
    return _dropDownView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
